# 211230 20:27

# 返回数字的迭代器：初始值为1，逐步递增1
# 最多到20
# raise StopIteration
class MyNumbers:
	def __iter__(self):
		self.a = 1
		return self
	
	def __next__(self):
		if self.a <= 20:
			x = self.a
			self.a += 1
			return x
		else:
			# StopIteration 异常用于标识迭代的完成
			raise StopIteration

myclass = MyNumbers()
myiter = iter(myclass)

# 最多到20
for x in myiter:
	print(x)
